package cn.wolfcode.trip.admin.controller;

import cn.wolfcode.trip.base.domain.SeeAll;
import cn.wolfcode.trip.base.query.SeeAllQueryObject;
import cn.wolfcode.trip.base.service.ISeeAllService;
import cn.wolfcode.trip.base.service.IStrategyService;
import cn.wolfcode.trip.base.service.ITravelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("/seeAll")
public class SeeAllController {

    @Autowired
    private ISeeAllService seeAllService;
    @Autowired
    private ITravelService travelService;
    @Autowired
    private IStrategyService strategyService;


    @RequestMapping("/list.do")
    public String upload( @ModelAttribute("qo")SeeAllQueryObject qo, Model model){
        model.addAttribute("result",seeAllService.query(qo));
        model.addAttribute("travels", travelService.list());
        model.addAttribute("strategies",strategyService.list());
        return "seeAll/list";
    }

    @RequestMapping("/saveOrUpdate.do")
    public String saveOrUpdate(SeeAll entity){
        seeAllService.saveOrUpdate(entity);
        return "redirect:/seeAll/list.do";
    }
}
